| 1 | |
| 2 | [[PageOutline(3-4, Sections)]] |
| 3 | |
| 4 | == !TryUploadSubtitles == |
| 5 | |
| 6 | === Intro === |
| 7 | |
| 8 | try to upload subtitles, perform pre-upload checking (i.e. check if subtitles already exist on server) |
| 9 | |
| 10 | |
| 11 | ---- |
| 12 | === Description === |
| 13 | |
| 14 | '''struct !TryUploadSubtitles(string $token, struct('cd1' => struct('subhash' => string $submd5hash, 'subfilename' => string $subfilename, 'moviehash' => string $moviehash, 'moviebytesize' => string double $moviesize, 'movietimems' => int $movietimems, 'movieframes' => int $movieframes, 'moviefps' => double $moviefps, 'moviefilename' => string $moviefilename) $subfile, 'cd2' => struct(...) $subfile) $subs)''' |
| 15 | |
| 16 | This function is used to perform pre-upload checking on given subtitle files ''subfiles''. It will check if given subtitles are well-formed, if they already exist on the server, etc. |
| 17 | |
| 18 | This must be called '''before''' [wiki:XmlRpcUploadSubtitles UploadSubtitles()]. |
| 19 | |
| 20 | It takes 2 parameters, first is the session token, second is a structure of information for subtitles to be uploaded, minimum ''cd1'' (one subtitle file) is required. |
| 21 | |
| 22 | The function returns ''alreadyindb'' = 1 when subtitles already exist in the database. |
| 23 | |
| 24 | When they do not exist, [wiki:XmlRpcSearchSubtitles SearchSubtitles()] is called and API tries to find existing subtitles based on ''moviehash/moviebytesize''. If some results are found, information is returned in ''data'' key as [wiki:XmlRpcSearchSubtitles SearchSubtitles()] return structure. |
| 25 | This is good for uploading - user should have imdbid field already filled. |
| 26 | |
| 27 | |
| 28 | ---- |
| 29 | === Parameters === |
| 30 | |
| 31 | Parameters structure: |
| 32 | {{{ |
| 33 | struct( |
| 34 | (string) [token], |
| 35 | struct( |
| 36 | struct( |
| 37 | (string) [subhash], |
| 38 | (string) [subfilename], |
| 39 | (string) [moviehash], |
| 40 | (double) [moviebytesize], |
| 41 | (int) [movietimems], |
| 42 | (int) [movieframes], |
| 43 | (double) [moviefps], |
| 44 | (string) [moviefilename] |
| 45 | ) [cd1], |
| 46 | struct( |
| 47 | ... same structure as cd1 ... |
| 48 | ) [cd2], |
| 49 | ... more subtitle file structures go here (if any) ... |
| 50 | ) |
| 51 | ) |
| 52 | }}} |
| 53 | |
| 54 | ''token (required)'':: |
| 55 | token string identifying user's session, taken from [XmlRpcLogIn LogIn] output structure. |
| 56 | ''subs'':: |
| 57 | structure of subtitle file information, contains one or more ''subfile'' structures |
| 58 | ''subfile'':: |
| 59 | * structure containing information about one subtitle file |
| 60 | * mandatory fields are: ''subhash'', ''subfilename'', ''[wiki:HashSourceCodes moviehash]'', ''moviebytesize'', ''moviefilename''. |
| 61 | * ''subhash'': MD5 hash of subtitle file contents |
| 62 | * ''subfilename'': subtitle filename |
| 63 | * 'moviehash'': hash calculated for the video file contents, see ''[wiki:HashSourceCodes Hash Source Codes]'' for various implementations |
| 64 | * ''moviebytesize': size of video file in bytes |
| 65 | * ''movietimems'': length of video in miliseconds |
| 66 | * ''movieframes': length of video in frames |
| 67 | * ''moviefps'': frame rate used in video file, e.g. 23.976 |
| 68 | * ''moviefilename'': video filename |
| 69 | |
| 70 | |
| 71 | ---- |
| 72 | === Return Values === |
| 73 | |
| 74 | Output is returned in this structure: |
| 75 | {{{ |
| 76 | struct( |
| 77 | (string) [status], |
| 78 | (int) [alreadyindb], |
| 79 | array( |
| 80 | struct( <--- this is the usual subtitle file structure |
| 81 | (string) [IDMovieImdb], |
| 82 | (string) [MovieName], |
| 83 | (string) [MovieYear], |
| 84 | (string) [MovieHash], |
| 85 | (string) [MovieReleaseName], |
| 86 | (string) [IDMovie], |
| 87 | (string) [MovieNameEng] |
| 88 | (string) [MovieImdbRating], |
| 89 | |
| 90 | + 2 extra indicator fields: |
| 91 | (string) [MoviefilenameWasAlreadyInDb] |
| 92 | (string) [HashWasAlreadyInDb] |
| 93 | |
| 94 | ) [subfile] |
| 95 | ) [data] |
| 96 | (double) [seconds] |
| 97 | ) |
| 98 | }}} |
| 99 | |
| 100 | and contains these elements: |
| 101 | ''status'':: |
| 102 | function result code, see [XmlRpcStatusCode list of status codes] |
| 103 | ''alreadyindb'':: |
| 104 | * indicator if subtitles are already available on the server. |
| 105 | * '''1''' if they are (upload should be interrupted, duplicate subtitle), |
| 106 | * '''0''' if they're not (upload can continue) |
| 107 | ''data'':: |
| 108 | * this array will contain one subtitle file structure (if found), |
| 109 | * this structure can be used to automatically gather information about movie, |
| 110 | * e.g. get IMDb ID so the user doesn't have to input it manually. |
| 111 | ''subfile'':: |
| 112 | * informational subtitle file structure |
| 113 | * see [wiki:XmlRpcStruSubFile subtitle file structure]. |
| 114 | * ''!HashWasAlreadyInDb'' - 0 means new ''moviehash'' was inserted into the database. |
| 115 | * ''!MoviefilenameWasAlreadyInDb'' - 0 means new ''moviefilename'' was inserted into the database. |
| 116 | ''seconds'':: |
| 117 | time taken to execute this command on server |
| 118 | |
| 119 | |
| 120 | ---- |
| 121 | === Implementations === |
| 122 | |
| 123 | There are currently no available sample implementations. |
| 124 | |
| 125 | |
| 126 | ---- |
| 127 | === Changelog === |
| 128 | |
| 129 | Version 1: created this function |
| 130 | |
| 131 | |
| 132 | ---- |
| 133 | === Examples === |
| 134 | |
| 135 | |
| 136 | ==== Input ==== |
| 137 | |
| 138 | {{{ |
| 139 | #!xml |
| 140 | <methodCall> |
| 141 | <methodName>TryUploadSubtitles</methodName> |
| 142 | <params> |
| 143 | <param> |
| 144 | <value><string>d5pnounn3ea5aja0nn4inqamf2</string></value> |
| 145 | </param> |
| 146 | <param> |
| 147 | <value> |
| 148 | <struct> |
| 149 | <member> |
| 150 | <name>cd1</name> |
| 151 | <value> |
| 152 | <struct> |
| 153 | <member> |
| 154 | <name>subhash</name> |
| 155 | <value><string>ebe86f4a0357d8c1d635ec49f77e27d6</string></value> |
| 156 | </member> |
| 157 | <member> |
| 158 | <name>subfilename</name> |
| 159 | <value><string>almost.heros.1998.dvdrip.xvid.fragment.cze.srt</string></value> |
| 160 | </member> |
| 161 | <member> |
| 162 | <name>moviehash</name> |
| 163 | <value><string>89ceb12ab48e3b1f</string></value> |
| 164 | </member> |
| 165 | <member> |
| 166 | <name>moviebytesize</name> |
| 167 | <value><double>731508736</double></value> |
| 168 | </member> |
| 169 | <member> |
| 170 | <name>moviefps</name> |
| 171 | <value><double>23.976</double></value> |
| 172 | </member> |
| 173 | <member> |
| 174 | <name>movietimems</name> |
| 175 | <value><int>5413204</int></value> |
| 176 | </member> |
| 177 | <member> |
| 178 | <name>movieframes</name> |
| 179 | <value><int>129787</int></value> |
| 180 | </member> |
| 181 | <member> |
| 182 | <name>moviefilename</name> |
| 183 | <value><string>almost.heros.1998.dvdrip.xvid.fragment.avi</string></value> |
| 184 | </member> |
| 185 | </struct> |
| 186 | </value> |
| 187 | </member> |
| 188 | ... more subtitle files go here (if any, e.g. for cd2, etc.) ... |
| 189 | </struct> |
| 190 | </value> |
| 191 | </param> |
| 192 | </params> |
| 193 | </methodCall> |
| 194 | }}} |
| 195 | |
| 196 | |
| 197 | ==== Output ==== |
| 198 | |
| 199 | {{{ |
| 200 | #!xml |
| 201 | <methodResponse> |
| 202 | <params> |
| 203 | <param> |
| 204 | <value> |
| 205 | <struct> |
| 206 | <member> |
| 207 | <name>status</name> |
| 208 | <value><string>200 OK</string></value> |
| 209 | </member> |
| 210 | <member> |
| 211 | <name>alreadyindb</name> |
| 212 | <value><int>0</int></value> |
| 213 | </member> |
| 214 | <member> |
| 215 | <name>data</name> |
| 216 | <value> |
| 217 | <array> |
| 218 | <data> |
| 219 | <value> |
| 220 | <struct> |
| 221 | <member> |
| 222 | <name>IDMovieImdb</name> |
| 223 | <value><string>119053</string></value> |
| 224 | </member> |
| 225 | <member> |
| 226 | <name>MovieName</name> |
| 227 | <value><string>Almost Heroes</string></value> |
| 228 | </member> |
| 229 | <member> |
| 230 | <name>MovieYear</name> |
| 231 | <value><string>1998</string></value> |
| 232 | </member> |
| 233 | <member> |
| 234 | <name>MovieHash</name> |
| 235 | <value><string>89ceb12ab48e3b1f</string></value> |
| 236 | </member> |
| 237 | <member> |
| 238 | <name>MovieReleaseName</name> |
| 239 | <value><string>Almost Heroes 1998 DVDRip XviD-FRAGMENT</string></value> |
| 240 | </member> |
| 241 | <member> |
| 242 | <name>IDMovie</name> |
| 243 | <value><string>13427</string></value> |
| 244 | </member> |
| 245 | <member> |
| 246 | <name>MovieNameEng</name> |
| 247 | <value><string>Almost History</string></value> |
| 248 | </member> |
| 249 | <member> |
| 250 | <name>MovieImdbRating</name> |
| 251 | <value><string>4.5</string></value> |
| 252 | </member> |
| 253 | |
| 254 | ... the usual subtitle file structure continues, not important ... |
| 255 | |
| 256 | </struct> |
| 257 | </value> |
| 258 | </data> |
| 259 | </array> |
| 260 | </value> |
| 261 | </member> |
| 262 | <member> |
| 263 | <name>seconds</name> |
| 264 | <value><double>0.065</double></value> |
| 265 | </member> |
| 266 | </struct> |
| 267 | </value> |
| 268 | </param> |
| 269 | </params> |
| 270 | </methodResponse> |
| 271 | }}} |
| 272 | |
| 273 | |
| 274 | ---- |
| 275 | === Notes === |
| 276 | |
| 277 | none yet |
| 278 | |
| 279 | |
| 280 | ---- |
| 281 | === See also === |
| 282 | |
| 283 | * [wiki:XmlRpcUploadSubtitles UploadSubtitles] |
| 284 | |
| 285 | |
| 286 | ---- |
| 287 | === Comments === |
| 288 | |
| 289 | add your comments, hints and suggestions here if you like ... |
| 290 | |
| 291 | |
| 292 | |
| 293 | [Prev] [wiki:XmlRpcIntro Home] [wiki:XmlRpcUploadSubtitles Next] |